package com.cain.DontTapTheWhiteTile.tool;

import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Color;

/**
 * Created by Cain on 2016/6/15.
 * 全局变量类
 */
public class Constants {

    /**
     * 禁止构造实体类
     */
    private Constants() {

    }

    public static final int BLOCK_WHITE = Color.argb(255, 245, 245, 245);
    public static final int BLOCK_BLACK = Color.argb(255, 32, 32, 32);
    public static final int BLOCK_YELLOW = Color.argb(255, 247, 231, 22);
    public static final int BLOCK_GRAY = Color.argb(255, 210, 210, 210);
    public static final int BLOCK_RED = Color.argb(255, 251, 62, 56);
    public static final int BLOCK_GREEN = Color.argb(255, 82, 214, 104);

    /**
     * 游戏模式
     */
    public static final int GAME_MODE_CLASSIC = 0;   //经典
    public static final int GAME_MODE_ARCADE = 1;   //街机

    /**
     * 游戏难度
     */
    public static final int GAME_DIFFICULTY_EASY = 0;   //简单：4X4
    public static final int GAME_DIFFICULTY_NORMAL = 1;   //正常：5X5
    public static final int GAME_DIFFICULTY_HARD = 2;   //困难：6X6

    /**
     * 最高点击次数
     */
    public static final int GAME_COUNT_FEW = 25;   //25次
    public static final int GAME_COUNT_MUCH = 50;   //50次
    public static final int GAME_COUNT_UNLIMITED = -1;   //无限次

    public static final String BEST_CLASSIC_EASY_FEW = "best_classic_easy_few";
    public static final String BEST_CLASSIC_EASY_MUCH = "best_classic_easy_much";
    public static final String BEST_CLASSIC_NORMAL_FEW = "best_classic_normal_few";
    public static final String BEST_CLASSIC_NORMAL_MUCH = "best_classic_normal_much";
    public static final String BEST_CLASSIC_HARD_FEW = "best_classic_hard_few";
    public static final String BEST_CLASSIC_HARD_MUCH = "best_classic_hard_much";

    public static final String BEST_ARCADE_EASY = "best_arcade_easy";
    public static final String BEST_ARCADE_NORMAL = "best_arcade_normal";
    public static final String BEST_ARCADE_HARD = "best_arcade_hard";

    public static final int GAME_OVER_NORMAL = 0;
    public static final int GAME_OVER_WRONG = 1;

    private static SharedPreferences preferences;   //轻量级存储，存放最佳记录
    private static SharedPreferences.Editor editor;

    static {
        preferences = MyApplication.getContext().getSharedPreferences("dont_tap_the_white_tile", Activity.MODE_PRIVATE);
        editor = preferences.edit();
    }

    /**
     * 存放long型数据
     * @param key
     * @param value
     */
    public static void put(String key, long value) {
        editor.putLong(key, value);
        editor.commit();
    }

    /**
     * 获取long型数据
     * @param key
     * @param defValue
     * @return
     */
    public static long getLong(String key, long defValue) {
        return preferences.getLong(key, defValue);
    }
}
